feat(responses): Add ability to return eventual response body from hooks #100
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comes from a need to support response bodies from hooks to drive Tekton Pipelines (https://github.com/tektoncd/pipeline). Tekton is a "new" (formally the Knative project) CI job runner that is k8s-native. Tekton runs k8s Jobs in-cluster to run various build stages.
In order to trigger a build initially however, you can do it manually through the Tekton dashboard or through their Triggers (https://github.com/tektoncd/triggers) project. Triggers bind webhook endpoints to Pipelines and allow a more closed-loop CI process. This Triggers project is still very new and has limited support for manipulating the webhook request payload (in this instance, a Github event).
Triggers do have this concept of "Interceptors" which essentially act as proxies from a webhook, through a custom k8s service (in our instance just an express server using the @octokit/webhooks.js lib) and back to the Tekton Pipeline to initiate a run. To this end, the Interceptor needs to be able to return a response body to the Pipeline in order for the Pipeline to know various things like commit hash, ref, repo name, clone url, etc.
Currently, the webhooks.js lib does not allow hooks to return data to/as the response body. This PR allows 1-n hooks to return objects that are later merged into a resulting response body which can then be utilized by the originator (or proxy in our case).
See #99 for the original ask.